<template>
  <el-dialog
    title="修改消费者数量"
    :close-on-click-modal="false"
    :visible.sync="visible"
  >
    <el-form
      :model="dataForm"
      ref="dataForm"
      @keyup.enter.native="dataFormSubmit()"
      label-width="80px"
    >
      <el-form-item label="callback_rates" prop="callback_rates" label-width="100px">
        <el-input v-model="dataForm.callback_rates" placeholder="参数值" label-width="100px"></el-input>
      </el-form-item>
      <el-form-item label="callback_rp" prop="callback_rp" label-width="100px">
        <el-input v-model="dataForm.callback_rp" placeholder="参数值"></el-input>
      </el-form-item>
      <el-form-item label="callback_room" prop="callback_room" label-width="100px">
        <el-input v-model="dataForm.callback_room" placeholder="参数值"></el-input>
      </el-form-item>
      <el-form-item label="callback_hotel" prop="callback_hotel" label-width="100px">
        <el-input v-model="dataForm.callback_hotel" placeholder="参数值"></el-input>
      </el-form-item>
      <el-form-item label="ht_up_down" prop="ht_up_down" label-width="100px">
        <el-input v-model="dataForm.ht_up_down" placeholder="参数值"></el-input>
      </el-form-item>
      <el-form-item label="send_all" prop="send_all" label-width="100px">
        <el-input v-model="dataForm.send_all" placeholder="参数值"></el-input>
      </el-form-item>
      <el-form-item label="delete_rp" prop="delete_rp" label-width="100px">
        <el-input v-model="dataForm.delete_rp" placeholder="参数值"></el-input>
      </el-form-item>
      <el-form-item label="change_hotel" prop="change_hotel" label-width="100px">
        <el-input v-model="dataForm.change_hotel" placeholder="参数值"></el-input>
      </el-form-item>
      <el-form-item label="change_room" prop="change_room" label-width="100px">
        <el-input v-model="dataForm.change_room" placeholder="参数值"></el-input>
      </el-form-item>
      <el-form-item label="change_rp" prop="change_rp" label-width="100px">
        <el-input v-model="dataForm.change_rp" placeholder="参数值"></el-input>
      </el-form-item>
      <el-form-item label="change_rates" prop="change_rates" label-width="100px">
        <el-input v-model="dataForm.change_rates" placeholder="参数值"></el-input>
      </el-form-item>
      <el-form-item label="xc_change_rates" prop="xc_change_rates" label-width="100px">
        <el-input v-model="dataForm.xc_change_rates" placeholder="参数值"></el-input>
      </el-form-item>
      <el-form-item label="hotel_id_list" prop="hotel_id_list" label-width="100px">
        <el-input v-model="dataForm.hotel_id_list" placeholder="参数值"></el-input>
      </el-form-item>
      <el-form-item label="hotel_id_list_all" prop="hotel_id_list_all" label-width="100px">
        <el-input v-model="dataForm.hotel_id_list_all" placeholder="参数值"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      visible: false,
      dataForm: {
        id: 0,
        callback_rates: "",
        callback_rp: "",
        callback_room: "",
        callback_hotel: "",
        ht_up_down: "",
        send_all: "",
        delete_rp: "",
        change_hotel: "",
        change_room: "",
        change_rp: "",
        change_rates: "",
        xc_change_rates: "",
        hotel_id_list: "",
        hotel_id_list_all: "",
      },
    };
  },
  methods: {
    init() {
      this.visible = true;
      this.$nextTick(() => {
        this.$refs["dataForm"].resetFields();
        
        this.$http({
        url: this.$http.adornUrl("/sys/mq/select"),
        method: "get",
        params: this.$http.adornParams(),
        }).then(({ data }) => {
        if (data && data.code === 0) {
            console.info(data)
            this.dataForm.id = data.mq.id;
            this.dataForm.callback_rates = data.mq.callbackRates;
            this.dataForm.callback_rp = data.mq.callbackRp;
            this.dataForm.callback_room = data.mq.callbackRoom;
            this.dataForm.callback_hotel = data.mq.callbackHotel;
            this.dataForm.ht_up_down = data.mq.htUpDown;
            this.dataForm.send_all = data.mq.sendAll;
            this.dataForm.delete_rp = data.mq.deleteRp;
            this.dataForm.change_rp = data.mq.changeRp;
            this.dataForm.change_hotel = data.mq.changeHotel;
            this.dataForm.change_room = data.mq.changeRoom;
            this.dataForm.change_rates = data.mq.changeRates;
            this.dataForm.hotel_id_list = data.mq.hotelIdList;
            this.dataForm.xc_change_rates = data.mq.xcChangeRates;
            this.dataForm.hotel_id_list_all = data.mq.hotelIdListAll;
        }
        });
        
      });
    },

    // 表单提交
    dataFormSubmit() {
      this.$refs["dataForm"].validate((valid) => {
        if (valid) {
            let dataMap = {
                id: this.dataForm.id,
                callbackRates: this.dataForm.callback_rates,
                callbackRp: this.dataForm.callback_rp,
                callbackRoom: this.dataForm.callback_room,
                callbackHotel: this.dataForm.callback_hotel,
                htUpDown: this.dataForm.ht_up_down,
                sendAll: this.dataForm.send_all,
                deleteRp: this.dataForm.delete_rp,
                changeHotel: this.dataForm.callback_hotel,
                changeRoom: this.dataForm.change_room,
                changeRp: this.dataForm.change_rp,
                changeRates: this.dataForm.change_rates,
                xcChangeRates: this.dataForm.xc_change_rates,
                hotelIdList: this.dataForm.hotel_id_list,
                hotelIdListAll: this.dataForm.hotel_id_list_all,
            }
          this.$http({
            url: this.$http.adornUrl("/sys/mq/update"),
            method: "post",
            data: this.$http.adornData(dataMap, false),
          }).then(({ data }) => {
            if (data && data.code === 0) {
              this.$message({
                message: "操作成功",
                type: "success",
                duration: 1500,
                onClose: () => {
                  this.visible = false;
                },
              });
            } else {
              this.$message.error(data.msg);
            }
          });
        }
      });
    },
  },
};
</script>
